home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 24
/
Aminet 24 (1998)(GTI - Schatztruhe)[!][Apr 1998].iso
/
Aminet
/
dev
/
c
/
AmiVoGL_MDEV.lha
/
src
/
drivers.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-07-16
|
15KB
|
731 lines
#include <stdio.h>
#include "vogl.h"
#include "vodevice.h"
/* ---------------------------------------------------------------------
* Prototypes:
*/
#ifdef __PROTOTYPE__
static void getdev(char *); /* drivers.c */
#else
static void getdev(); /* drivers.c */
#endif
/* ---------------------------------------------------------------------
* Driver Prototypes:
*/
#ifdef __PROTOTYPE__
#ifdef AMIGA
void _AMIGA_devcpy(void); /* amiga.c */
#endif
#ifdef apollo
int _APOLLO_devcpy(void); /* apollo.c */
#endif
#ifdef CGA
int _cga_devcpy(void); /* cga.c */
#endif
#ifdef DECX11
int _DECX11_devcpy(void); /* decX11.c */
#endif
#ifdef DXY
int _DXY_devcpy(void); /* hpdxy.c */
#endif
#ifdef EGA
int _ega_devcpy(void); /* ega.c */
#endif
#ifdef GRX
int _grx_devcpy(void); /* grx.c */
#endif
#ifdef HERCULES
#endif
#ifdef HGC
int _hgc_devcpy(void); /* hgc.c */
#endif
#ifdef HPGL
int _HPGL_A1_devcpy(void); /* hpdxy.c */
int _HPGL_A2_devcpy(void); /* hpdxy.c */
int _HPGL_A3_devcpy(void); /* hpdxy.c */
int _HPGL_A4_devcpy(void); /* hpdxy.c */
#endif
#ifdef NeXT
int _NeXT_devcpy(void); /* NeXT.c */
#endif
#ifdef POSTSCRIPT
int _CPS_devcpy(void); /* ps.c */
int _PS_devcpy(void); /* ps.c */
int _PSP_devcpy(void); /* ps.c */
int _PCPS_devcpy(void); /* ps.c */
int _LASER_devcpy(void); /* ps.c */
#endif
#ifdef SIGMA
int _sigma_devcpy(void); /* sigma.c */
#endif
#ifdef SUN
int _SUN_devcpy(void); /* sun.c */
#endif
#ifdef TEK
int _TEK_devcpy(void); /* tek.c */
#endif
#ifdef VGA
int _vga_devcpy(void); /* vga.c */
#endif
#ifdef X11
int _X11_devcpy(void); /* X11.c */
#endif
#endif /* __PROTOTYPE__ */
/* ---------------------------------------------------------------------
* Local Variables:
*/
static FILE *fp = stdout;
static int allocated = 0;
struct vdev vdevice;
/* --------------------------------------------------------------------- */
/* device-independent function routines */
/*
* voutput
*
* redirect output - only for postscript, hpgl (this is not a feature)
*/
void voutput(char *path)
{
char buf[128];
if ((fp = fopen(path, "w")) == (FILE *)NULL) {
sprintf(buf, "voutput: couldn't open %s", path);
verror(buf);
}
}
/* ------------------------------------------------------------------------ */
/*
* _voutfile
*
* return a pointer to the current output file - designed for internal
* use only.
*/
FILE * _voutfile(void)
{
return(fp);
}
/* ------------------------------------------------------------------------ */
/*
* verror
*
* print an error on the graphics device, and then exit. Only called
* for fatal errors. We assume that stderr is always there.
*
*/
void verror(char *str)
{
if (vdevice.initialised)
gexit();
fprintf(stderr, "%s\n", str);
exit(1);
}
/* ------------------------------------------------------------------------ */
/*
* gexit
*
* exit the vogl/vogle system
*
*/
void gexit(void)
{
if (!vdevice.initialised)
verror("gexit: vogl not initialised");
(*vdevice.dev.Vexit)();
vdevice.devname = (char *)NULL;
vdevice.initialised = 0;
fp = stdout;
}
/* ------------------------------------------------------------------------ */
/*
* getdev
*
* get the appropriate device table structure
*/
static void getdev(char *device)
{
#ifdef AMIGA
if (strncmp(device,"amiga",5) == 0) _AMIGA_devcpy();
else if (strncmp(device,"AMIGA",5) == 0) _AMIGA_devcpy();
else
#endif
#ifdef SUN
if (strncmp(device, "sun", 3) == 0) _SUN_devcpy();
else
#endif
#ifdef X11
if (strncmp(device, "X11", 3) == 0) _X11_devcpy();
else
#endif
#ifdef DECX11
if (strncmp(device, "decX11", 6) == 0) _DECX11_devcpy();
else
#endif
#ifdef NeXT
if (strncmp(device, "NeXT", 4) == 0) _NeXT_devcpy();
else
#endif
#ifdef POSTSCRIPT
if (strncmp(device, "postscript", 10) == 0) {
_PS_devcpy();
}
else
if (strncmp(device, "ppostscript", 11) == 0) {
_PSP_devcpy();
}
else
#endif
#ifdef HPGL
if (strncmp(device, "hpgla1", 6) == 0) _HPGL_A1_devcpy();
else if (strncmp(device, "hpgla3", 6) == 0) _HPGL_A3_devcpy();
else if (strncmp(device, "hpgla4", 6) == 0) _HPGL_A4_devcpy();
else if (strncmp(device, "hpgla2", 6) == 0 || strncmp(device, "hpgl", 4) == 0)
_HPGL_A2_devcpy();
else
#endif
#ifdef DXY
if (strncmp(device, "dxy", 3) == 0) _DXY_devcpy();
else
#endif
#ifdef TEK
if (strncmp(device, "tek", 3) == 0) _TEK_devcpy();
else
#endif
#ifdef HERCULES
if (strncmp(device, "hercules", 8) == 0) _hgc_devcpy();
else
#endif
#ifdef CGA
if (strncmp(device, "cga", 3) == 0) _cga_devcpy();
else
#endif
#ifdef EGA
if (strncmp(device, "ega", 3) == 0) _ega_devcpy();
else
#endif
#ifdef VGA
if (strncmp(device, "vga", 3) == 0) _vga_devcpy();
else
#endif
#ifdef SIGMA
if (strncmp(device, "sigma", 5) == 0) _sigma_devcpy();
else
#endif
{
if(!device || *device == 0)
fprintf(stderr,
"vogl: expected the enviroment variable VDEVICE to be set to the desired device.\n");
else fprintf(stderr, "vogl: %s is an invalid device type\n", device);
fprintf(stderr, "The devices compiled into this library are:\n");
#ifdef SUN
fprintf(stderr, "sun\n");
#endif
#ifdef AMIGA
fprintf(stderr,"amiga\n");
#endif
#ifdef X11
fprintf(stderr, "X11\n");
#endif
#ifdef DECX11
fprintf(stderr, "decX11\n");
#endif
#ifdef NeXT
fprintf(stderr, "NeXT\n");
#endif
#ifdef POSTSCRIPT
fprintf(stderr, "postscript\n");
fprintf(stderr, "ppostscript\n");
#endif
#ifdef HPGL
fprintf(stderr, "hpgla1\n");
fprintf(stderr, "hpgla2 (or hpgl)\n");
fprintf(stderr, "hpgla3\n");
fprintf(stderr, "hpgla4\n");
#endif
#ifdef DXY
fprintf(stderr, "dxy\n");
#endif
#ifdef TEK
fprintf(stderr, "tek\n");
#endif
#ifdef HERCULES
fprintf(stderr, "hercules\n");
#endif
#ifdef CGA
fprintf(stderr, "cga\n");
#endif
#ifdef EGA
fprintf(stderr, "ega\n");
#endif
#ifdef VGA
fprintf(stderr, "vga\n");
#endif
#ifdef SIGMA
fprintf(stderr, "sigma\n");
#endif
exit(1);
}
}
/* ------------------------------------------------------------------------ */
/*
* vinit
*
* Just set the device name. ginit and winopen are basically
* the same as the VOGLE the vinit function.
*
*/
void vinit(char *device)
{
vdevice.devname = device;
}
/* ------------------------------------------------------------------------ */
/*
* winopen
*
* use the more modern winopen call (this really calls ginit),
* we use the title if we can
*/
long winopen(char *title)
{
vdevice.wintitle = title;
ginit();
return(1L);
}
/* ------------------------------------------------------------------------ */
/*
* ginit
*
* by default we check the environment variable, if nothing
* is set we use the value passed to us by the vinit call.
*/
void ginit(void)
{
char *dev= NULL;
int i;
if (vdevice.devname == (char *)NULL) {
if ((dev = getenv("VDEVICE")) == (char *)NULL) getdev("");
else getdev(dev);
}
else getdev(vdevice.devname);
if (vdevice.initialised) gexit();
if (!allocated) {
allocated = 1;
vdevice.transmat = (Mstack *)vallocate(sizeof(Mstack));
vdevice.transmat->back = (Mstack *)NULL;
vdevice.attr = (Astack *)vallocate(sizeof(Astack));
vdevice.attr->back = (Astack *)NULL;
vdevice.viewport